load("@rules_cc//cc:defs.bzl", "cc_library")
load("@rules_cc//cc:defs.bzl", "cc_proto_library") 
load("@rules_proto//proto:defs.bzl", "proto_library") 
load("@rules_cuda//cuda:defs.bzl", "cuda_library")

package(default_visibility = ["//visibility:public"])

cc_proto_library( 
    name = "ipcamera_cc_pb", 
    deps = [":ipcamera_pb"], 
)

proto_library( 
    name = "ipcamera_pb", 
    srcs = ["ipcamera/proto/header.proto",
        "ipcamera/proto/sensor_image.proto"
    ], 
)

cuda_library(
    name = "apigpu-yuv2rgb",
    srcs = [
        "ipcamera/src/apigpu-yuv2rgb.cu",
    ],
    hdrs = [
        "ipcamera/include/apigpu-yuv2rgb.h",
        "ipcamera/include/api-structs.h",
        "ipcamera/include/log.h",
        "camera_base.h",
    ],
    deps = [
        "@com_github_google_glog//:glog",
        "@cuda//:cuda",
        "@ffmpeg//:ffmpeg",
        "//base/cv_image:base_cv_image",
    ],
)

cc_library(
    name = "base_camera_device",
    srcs = glob(
        [
            "*.cc",
            "*.h",
            "**/*.cc",
            "**/*.h",
            "**/**/*.cc",
            "**/**/*.h",
        ],
        exclude = [
            "ut/camera_test.cc",
            "test_tool/test_tool.cc",
            "ipcamera/apps/apidemos.cc",
        ],
    ),
    includes = [
        ".",
    ],
    deps = [
        "@airosrt//:airosrt",
        "@protobuf_import//:protobuf_import",
        "@com_google_googletest//:gtest_main",
        "@com_github_google_glog//:glog",
        "@com_github_gflags_gflags//:gflags",
        "@cuda//:cuda",
        "@hiksdk//:hiksdk",
        "@dahua-sdk//:dahua-sdk",
        "@ffmpeg//:ffmpeg",
        "//base/cv_image:base_cv_image",
        "//base/common:base_common",
        "//base/blob:base_blob",
        "ipcamera_cc_pb",
        "@fastrtps//:fastrtps",
        "apigpu-yuv2rgb",
        "@opencv//:opencv",
        "@video_decoder//:video_decoder"
    ],
)

cc_binary(
    name = "apidemos",
    srcs = glob(
        [
            "ipcamera/apps/apidemos.cc",
        ]
    ),
    linkopts = [
        "-pthread -lz -lrt -luuid -ldl"
    ],
    deps = [
        "base_camera_device",
    ],
)

# cc_test( #TODO
#     name = "base_camera_ut",
#     srcs = [
#         "ut/camera_test.cc",
#         "camera_factory.h",
#         "camera_base.h",
#     ],
#     includes = [
#         ".",
#     ],
#     linkopts = [
#         "-L/airos-al/bazel-bin/camera",
#         "-lcamera_device",
#         "-pthread"
#     ],
#     deps = [
#         "@com_google_googletest//:gtest_main",
#         "base_camera_device"
#     ],
# )

# cc_binary(
#     name = "base_camera_test_tool",
#     srcs = [
#         "test_tool/test_tool.cc",
#         "camera_factory.h",
#         "camera_base.h",
#     ],
#     includes = [
#         ".",
#     ],
#     linkopts = [
#         "-L/airos-al/bazel-bin/camera",
#         "-lcamera_device",
#         "-pthread"
#     ],
#     deps = [
#         "@yaml_cpp//:yaml_cpp",
#         "base_camera_device"
#     ],
# )